<template>
  <div class="order">
    <Input placeholder="请输入作业单号" v-model="value" class="order__input" />
  </div>
</template>

<script lang="ts">
import { Component, Vue, Watch } from 'vue-property-decorator';
import Input from '@/components/input';
import { storage } from '@/modules/storage';

@Component({
  name: 'Order',
  components: {
    Input
  }
})
export default class Order extends Vue {
  private value: string = '';

  mounted() {
    this.value = storage.get('order') ?? '';
  }

  @Watch('value')
  handleInputChange(val: string) {
    const replacedValue = val.replace(/[^0-9a-zA-Z-_]/g, '');
    this.value = replacedValue;
    storage.set('order', replacedValue);
  }

}
</script>

<style lang="scss" scoped>
.order {
  background: #fff;
  padding: 16px 12px;

  &__input {
    width: 100%;
  }
}
</style>
